ifndef HOST_CXX
HOST_CXX:=g++
endif
ifndef TARGET_CC
TARGET_CC:=sw5gcc
endif

PLUGIN_PATH:=$(shell $(TARGET_CC) -print-file-name=plugin)
# CC1_PATH:=/usr/sw-mpp/swcc/new_compiler_710/swgcc710-tools-5A-98/usr_sw5/lib64
# LIBS:=-L$(PLUGIN_PATH) -lcc1plugin -lcp1plugin -Wl,-rpath=$(PLUGIN_PATH) -L$(CC1_PATH) -lcc1 -Wl,-rpath=$(CC1_PATH)
PLUGIN_INC:=$(PLUGIN_PATH)/include
CFLAGS:=-fno-rtti -fPIC -g
MODULES=literal-to-gprel cast-protect ifmov force-unroll split vect-alias patch-builtin iv-res
SRCS:=$(patsubst %, %.cpp, $(MODULES)) nohp.cpp
OBJS:=$(patsubst %, %.o, $(MODULES)) nohp.o
DEPS:=$(patsubst %, %.dep, $(MODULES)) nohp.dep
all: ../lib/nohp.so
../lib/nohp.so: $(OBJS)
	$(HOST_CXX) -shared $(OBJS) -o $@
%.o: %.cpp
	$(HOST_CXX) -I$(PLUGIN_INC) $(CFLAGS) -c $< -o $@
%.dep: %.cpp
	$(HOST_CXX) -MM $< -o $@
-include $(DEPS)
.PHONY:
clean:
	rm ../lib/nohp.so *.o

